﻿using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

namespace YJKAreaCutter.Utils.InternalCorner
{
	public class ListObjectDeepCloneUtils
	{
		public static T DeepClone<T>(T Object)
		{
			T result;
			using (Stream stream = new MemoryStream())
			{
				BinaryFormatter binaryFormatter = new BinaryFormatter();
				((IFormatter)binaryFormatter).Serialize(stream, Object);
				stream.Seek(0L, SeekOrigin.Begin);
				result = (T)((object)((IFormatter)binaryFormatter).Deserialize(stream));
			}
			return result;
		}
	}
}
